package com.augurit.common.common.http.kt.interceptor

import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response

/**
 *  author : yanghaozhang
 *  date : 2022/5/4 20:44
 *  description :
 */

interface GlobalHttpHandler {

    fun onHttpResultResponse(chain: Interceptor.Chain, response: Response): Response

    fun onHttpRequestBefore(chain: Interceptor.Chain, request: Request): Request

    companion object {
        /**
         * 空实现
         */
        val EMPTY: GlobalHttpHandler = object : GlobalHttpHandler {
            override fun onHttpResultResponse(chain: Interceptor.Chain, response: Response): Response {
                //不管是否处理, 都必须将 response 返回出去
                return response
            }

            override fun onHttpRequestBefore(chain: Interceptor.Chain, request: Request): Request {
                //不管是否处理, 都必须将 request 返回出去
                return request
            }
        }
    }
}